package pku.tcs.wsc.solver;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;

import org.jdom.JDOMException;


import pku.tcs.wsc.service.Service;



public class Checker {
	
	//	response time qos
	public static long solutionResponseTime = 0;
	//throughput qos
	public static float solutionThroughput = 0;
	
	public static void checkSolution(ArrayList<Service> solution){
		int n=solution.size();
		solutionResponseTime = solution.get(0).responseTime;
		solutionThroughput = solution.get(0).throughput;
		for(int i = 1 ; i < n ; i++){
			solutionResponseTime += solution.get(i).responseTime;
			if(solutionThroughput > solution.get(i).throughput)
				solutionThroughput = solution.get(i).throughput;
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) throws FileNotFoundException,
	JDOMException, IOException {
		// TODO Auto-generated method stub
		String owlFile = "data/testSet_V1/Taxonomy.owl";
		String challengeFile = "data/testSet_V1/Challenge.wsdl";
		String wsdlFile = "data/testSet_V1/Services.wsdl";
		String wslaFile = "data/testSet_V1/Servicelevelagreements.wsla";
		String result = "./data/ParseResult.txt";

		Solver.setParserResultPath(result);
		Solver.setWSDLFilePath(wsdlFile);
		Solver.setOWLFilePath(owlFile);
		Solver.setWSLAFilePath(wslaFile);
		Solver.setChallengeFilePath(challengeFile);
		
		ArrayList<Service> v= Solver.solve();
		for(Service s:v)
			System.out.println(s.id+" "+s.responseTime+" "+s.throughput);
		

		checkSolution(v);
		System.out.println(solutionResponseTime);
		System.out.println(solutionThroughput);

	}

}


